package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoInformationContent;
import com.muyu.danmo.service.IDanmoInformationContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 个人信息简介Controller
 * 
 * @author yangle
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/informationContent")
public class DanmoInformationContentController extends BaseController
{
    @Autowired
    private IDanmoInformationContentService danmoInformationContentService;

    /**
     * 查询个人信息简介列表
     */
//    @RequiresPermissions("system:informationContent:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoInformationContent>> list(DanmoInformationContent danmoInformationContent)
    {
        startPage();
        List<DanmoInformationContent> list = danmoInformationContentService.selectDanmoInformationContentList(danmoInformationContent);
        return getDataTable(list);
    }

    /**
     * 导出个人信息简介列表
     */
//    @RequiresPermissions("system:informationContent:export")
    @Log(title = "个人信息简介", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationContent danmoInformationContent)
    {
        List<DanmoInformationContent> list = danmoInformationContentService.selectDanmoInformationContentList(danmoInformationContent);
        ExcelUtil<DanmoInformationContent> util = new ExcelUtil<DanmoInformationContent>(DanmoInformationContent.class);
        util.exportExcel(response, list, "个人信息简介数据");
    }

    /**
     * 获取个人信息简介详细信息
     */
//    @RequiresPermissions("system:informationContent:query")
    @GetMapping(value = "/{contentId}")
    public Result getInfo(@PathVariable("contentId") Long contentId)
    {
        return success(danmoInformationContentService.selectDanmoInformationContentByContentId(contentId));
    }

    /**
     * 新增个人信息简介
     */
//    @RequiresPermissions("system:informationContent:add")
    @Log(title = "个人信息简介", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoInformationContent danmoInformationContent)
    {
        return toAjax(danmoInformationContentService.insertDanmoInformationContent(danmoInformationContent));
    }

    /**
     * 修改个人信息简介
     */
//    @RequiresPermissions("system:informationContent:edit")
    @Log(title = "个人信息简介", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoInformationContent danmoInformationContent)
    {
        return toAjax(danmoInformationContentService.updateDanmoInformationContent(danmoInformationContent));
    }

    /**
     * 删除个人信息简介
     */
//    @RequiresPermissions("system:informationContent:remove")
    @Log(title = "个人信息简介", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contentIds}")
    public Result remove(@PathVariable Long[] contentIds)
    {
        return toAjax(danmoInformationContentService.deleteDanmoInformationContentByContentIds(contentIds));
    }
}
